<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Banners Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style media="screen">
        .shadow {
            position:fixed;
            width: 100%;
            height: 100%;
            background: #000;
            opacity: 0.3;
            filter: Alpha(opacity=30);/* IE8 以及更早的浏览器，不透明度 */
            left: 0px;
            top: 0px;

        }
        .mod-dialog {
            width: 300px;
            height: 200px;
            border: 1px solid black;
            background: #fff;
            position: fixed;
            left: 50%;
            top: 50%;
            margin-left: -150px;
            margin-top: -100px;
        }
    </style>
</head>
<body>
    <% include components/top.inc.ejs %>
    <div class="content-wrap">
        <div>
            <!-- ?表示提交当前目录,用act区分动作 -->
            <form action="?act=add" method="post">
                标题：<input type="text" name="title" ><br>
                描述：<textarea name="desc" ></textarea><br>
                链接：<input type="text" name="href"><br>
                <input type="submit" value="添加">
            </form>
        </div>
        <div>
            <table border="1" width='100%'>
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>标题</th>
                        <th>描述</th>
                        <th>链接</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <% for (let i =0; i < details.length; i++) { %>
                    <tr>
                        <td><%=details[i].ID%></td>
                        <td><%=details[i].title%></td>
                        <td><%=details[i].description%></td>
                        <td><%=details[i].href%></td>
                        <td>
                            <a href="?act=update&id=<%=details[i].ID%>">修改</a>
                            <a href="?act=del&id=<%=details[i].ID%>" onclick="return confirm('你确定要删除吗？')">删除</a>
                        </td>
                    </tr>
                    <% } %>
                </tbody>
            </table>
        </div>
        <% if (typeof updateDetail != 'undefined') {%>
        <div class="shadow"></div>
        <div class="mod-dialog">
            <!-- ?表示提交当前目录,用act区分动作 -->
            <form action="?" method="post">
                <input type="hidden" name="update_id" value="<%= updateDetail.ID %>">
                标题：<input type="text" name="title" value="<%= updateDetail.title %>"><br>
                描述：<textarea name="desc" ><%= updateDetail.description %></textarea><br>
                链接：<input type="text" name="href" value="<%= updateDetail.href %>"><br>
                <input type="submit" value="修改">
                <a href="/admin/banners">取消修改</a>
            </form>
        </div>
        <% } %>
    </div>
</body>
</html>